<%@tag description="Places a single GroundOverlay in the KML file" pageEncoding="UTF-8"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@attribute name="capabilities" required="true" type="uk.ac.rdg.resc.wms2kml.WMSCapabilities" description="Capabilities object"%>
<%@attribute name="layer" required="true" type="uk.ac.rdg.resc.wms2kml.Layer" description="Layer object"%>
<%@attribute name="elevation" required="false" description="Elevation value"%>
<%@attribute name="time" required="false" description="Time value"%>
<c:set var="href" value="${capabilities.getMapUrl}VERSION=${capabilities.version}&amp;REQUEST=GetMap&amp;LAYERS=${layer.name}&amp;STYLES=&amp;BBOX=${layer.bbox.westLon},${layer.bbox.southLat},${layer.bbox.eastLon},${layer.bbox.northLat}&amp;${capabilities.latLonProjectionCode}&amp;WIDTH=256&amp;HEIGHT=256&amp;FORMAT=${capabilities.compatibleImageFormat}&amp;TRANSPARENT=TRUE"/>
<c:set var="name" value="${layer.title}"/>
<c:set var="useDescription" value="true"/>
<c:if test="${not empty elevation}">
    <c:set var="name" value="${elevation} ${layer.elevationUnits}"/>
    <c:set var="useDescription" value="false"/>
    <c:set var="href" value="${href}&amp;ELEVATION=${elevation}"/>
</c:if>
<c:if test="${not empty time}">
    <c:set var="name" value="${time}"/>
    <c:set var="useDescription" value="false"/>
    <c:set var="href" value="${href}&amp;TIME=${time}"/>
</c:if>
<GroundOverlay>
    <name>${name}</name>
    <c:if test="${useDescription}">
        <description>${layer.description}</description>
    </c:if>
    <visibility>0</visibility>
    <LatLonBox>
        <north>${layer.bbox.northLat}</north>
        <south>${layer.bbox.southLat}</south>
        <east>${layer.bbox.eastLon}</east>
        <west>${layer.bbox.westLon}</west>
    </LatLonBox>
    <c:if test="${not empty time}">
        <TimeStamp>
            <when>${time}</when>
        </TimeStamp>
    </c:if>
    <Icon>
        <href>${href}</href>
    </Icon>
    <%-- TODO: region, legend, STYLE --%>
</GroundOverlay>